package tr.edu.metu.is.mega.server.timer;

import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
 * Timer manager servlet.
 */
public class TimerServlet extends HttpServlet {

    public static final long HOUR_IN_MILLIS = 3600000;

    public static final long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS;

    private static final long serialVersionUID = 989878020706123551L;

    /**
     * {@inheritDoc}
     */
    @Override
    public void init() throws ServletException {
        super.init();
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {

            @Override
            public void run() {
                ActivityNotifier.doJob();
                AnnouncementNotifier.doJob();
                StudentExpireController.doJob();
                ReviewerNotifier.doJob();
            }
        }, 1000, HOUR_IN_MILLIS);
    }

}
